Repository navigation
Conversation
Issue 1: Null Pointer Risk (CRITICAL)Location: List<URL> storageJars =
FileUtils.searchJarFilesForStorage(
Common.appStarterDir().resolve("zeta"),
config.getStorage().getStoragePluginConfig().get("storage.type"));Related Context:
Issue Description:
This coding style reduces code readability and robustness. Potential Risks:
Impact Scope:
Severity: CRITICAL (Although it won't crash currently, it's a bad practice) Improvement Suggestions: // CheckpointService.java
public CheckpointService(CheckpointConfig config) {
ClassLoader storageClassLoader = Thread.currentThread().getContextClassLoader();
// Safely obtain storage.type
CheckpointStorageConfig storageConfig = config.getStorage();
String storageType = null;
if (storageConfig != null && storageConfig.getStoragePluginConfig() != null) {
storageType = storageConfig.getStoragePluginConfig().get("storage.type");
}
List<URL> storageJars =
FileUtils.searchJarFilesForStorage(
Common.appStarterDir().resolve("zeta"),
storageType);
if (!storageJars.isEmpty()) {
storageClassLoader =
new URLClassLoader(storageJars.toArray(new URL[0]), storageClassLoader);
}
try (TemporaryClassLoaderContext ignored =
TemporaryClassLoaderContext.of(storageClassLoader)) {
this.checkpointStorage =
FactoryUtil.discoverFactory(
Thread.currentThread().getContextClassLoader(),
CheckpointStorageFactory.class,
config.getStorage().getStorage())
.create(config.getStorage().getStoragePluginConfig());
}
}Rationale: Explicitly check each layer that could be Issue 2: URLClassLoader Not Closed (MAJOR)Location:
// CheckpointService.java
if (!storageJars.isEmpty()) {
storageClassLoader =
new URLClassLoader(storageJars.toArray(new URL[0]), storageClassLoader);
}
try (TemporaryClassLoaderContext ignored =
TemporaryClassLoaderContext.of(storageClassLoader)) {
// ...
}Related Context:
Issue Description: Java 7 introduced the
Potential Risks:
Impact Scope:
Severity: MAJOR (Limited impact in normal usage scenarios, but may cause problems in specific scenarios) Improvement Suggestions: // CheckpointService.java
public class CheckpointService {
@Getter
private CheckpointStorage checkpointStorage;
private Serializer serializer = new ProtoStuffSerializer();
private URLClassLoader storageClassLoader; // Save reference for later closing
@SneakyThrows
public CheckpointService(CheckpointConfig config) {
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
List<URL> storageJars =
FileUtils.searchJarFilesForStorage(
Common.appStarterDir().resolve("zeta"),
config.getStorage().getStoragePluginConfig().get("storage.type"));
if (!storageJars.isEmpty()) {
this.storageClassLoader =
new URLClassLoader(storageJars.toArray(new URL[0]), currentClassLoader);
currentClassLoader = this.storageClassLoader;
}
try (TemporaryClassLoaderContext ignored =
TemporaryClassLoaderContext.of(currentClassLoader)) {
this.checkpointStorage =
FactoryUtil.discoverFactory(
Thread.currentThread().getContextClassLoader(),
CheckpointStorageFactory.class,
config.getStorage().getStorage())
.create(config.getStorage().getStoragePluginConfig());
}
}
/**
* Release resources held by this service.
* Should be called when the service is no longer needed.
*/
public void close() {
if (storageClassLoader != null) {
try {
storageClassLoader.close();
} catch (IOException e) {
log.warn("Failed to close storage classloader", e);
}
}
}
}For // FileMapStore.java
public class FileMapStore implements MapStore<Object, Object>, MapLoaderLifecycleSupport {
private IMapStorage mapStorage;
private URLClassLoader storageClassLoader; // Save reference
@Override
public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
Map<String, Object> initMap = new HashMap<>(Maps.fromProperties(properties));
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
List<URL> storageJars =
FileUtils.searchJarFilesForStorage(
Common.appStarterDir().resolve("zeta"),
properties.getProperty("storage.type"));
if (!storageJars.isEmpty()) {
this.storageClassLoader =
new URLClassLoader(storageJars.toArray(new URL[0]), currentClassLoader);
currentClassLoader = this.storageClassLoader;
}
} catch (IOException e) {
throw new IllegalStateException("Failed to load Zeta storage jars", e);
}
try (TemporaryClassLoaderContext ignored =
TemporaryClassLoaderContext.of(currentClassLoader)) {
this.mapStorage =
FactoryUtil.discoverFactory(
Thread.currentThread().getContextClassLoader(),
IMapStorageFactory.class,
(String) initMap.get("type"))
.create(initMap);
}
}
@Override
public void destroy() {
// Close mapStorage first
if (mapStorage != null) {
mapStorage.destroy(false);
}
// Then close classloader
if (storageClassLoader != null) {
try {
storageClassLoader.close();
log.debug("Closed storage classloader for FileMapStore");
} catch (IOException e) {
log.warn("Failed to close storage classloader", e);
}
}
}
}Rationale: Explicitly manage resource lifecycle to avoid resource leaks, which is a best practice for Java resource management. Issue 3: Path Traversal Risk (MAJOR)Location: String normalizedStorageType = storageType.trim().toLowerCase(Locale.ROOT);
Path storageDir = zetaDirectory.resolve(normalizedStorageType);Related Context:
Issue Description: For example: Path zetaDir = Paths.get("/opt/seatunnel/starter/zeta");
Path storageDir = zetaDir.resolve("../../etc");
// storageDir = /opt/seatunnel/etcThis could lead to malicious configuration accessing arbitrary directories. Although:
But if an attacker is able to:
Then arbitrary JAR files could be loaded. Potential Risks:
Impact Scope:
Severity: MAJOR (Requires configuration file tampering to exploit, but still a security risk) Improvement Suggestions: // FileUtils.java
public static List<URL> searchJarFilesForStorage(
@NonNull Path zetaDirectory, String storageType) throws IOException {
if (!Files.isDirectory(zetaDirectory)) {
log.debug("Zeta directory does not exist: {}", zetaDirectory);
return new ArrayList<>();
}
if (storageType == null || storageType.trim().isEmpty()) {
return searchJarFiles(zetaDirectory);
}
// Validate the legitimacy of storage type
String normalizedStorageType = storageType.trim().toLowerCase(Locale.ROOT);
// Add path traversal protection: only allow letters, numbers, underscores, hyphens
if (!normalizedStorageType.matches("^[a-z0-9_-]+$")) {
throw new IllegalArgumentException(
"Invalid storage type: '" + storageType + "'. " +
"Storage type must contain only letters, numbers, underscores, and hyphens.");
}
// Verify that the resolved path is still under zetaDirectory
Path storageDir = zetaDirectory.resolve(normalizedStorageType);
if (!storageDir.startsWith(zetaDirectory)) {
throw new IllegalArgumentException(
"Invalid storage type: '" + storageType + "'. " +
"Path traversal detected.");
}
List<URL> jars = new ArrayList<>();
boolean splitLayoutDetected = false;
Path commonDir = zetaDirectory.resolve("common");
if (Files.isDirectory(commonDir)) {
splitLayoutDetected = true;
jars.addAll(searchJarFiles(commonDir));
}
if (Files.isDirectory(storageDir)) {
splitLayoutDetected = true;
jars.addAll(searchJarFiles(storageDir));
}
if (splitLayoutDetected) {
log.info(
"Loaded {} storage JAR(s) for storage type '{}' from {}",
jars.size(),
normalizedStorageType,
zetaDirectory);
return jars;
}
log.info(
"No split Zeta storage directory found for storage type '{}', scan all JAR(s) under {} instead",
normalizedStorageType,
zetaDirectory);
return searchJarFiles(zetaDirectory);
}Rationale: Defensive programming - even if the risk is low in the current scenario, security best practices should still be followed. Issue 4: Insufficient Test Coverage (MINOR)Location: Issue Description:
Potential Risks:
Impact Scope:
Severity: MINOR (Current logic is simple, but comprehensive testing can improve code quality) Improvement Suggestions: // FileUtilsTest.java
@Test
public void testSearchJarFilesForStorageWithNullStorageType() throws Exception {
Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
Path jar = Files.createFile(zetaDir.resolve("test.jar"));
List<URL> urls = FileUtils.searchJarFilesForStorage(zetaDir, null);
Assertions.assertEquals(1, urls.size());
Assertions.assertTrue(urls.get(0).toString().contains("test.jar"));
}
@Test
public void testSearchJarFilesForStorageWithEmptyStorageType() throws Exception {
Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
Path jar = Files.createFile(zetaDir.resolve("test.jar"));
List<URL> urls = FileUtils.searchJarFilesForStorage(zetaDir, " ");
Assertions.assertEquals(1, urls.size());
}
@Test
public void testSearchJarFilesForStorageCaseInsensitive() throws Exception {
Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
Files.createDirectories(zetaDir.resolve("s3"));
Path jar = Files.createFile(zetaDir.resolve("s3").resolve("s3.jar"));
// Test various case combinations
for (String type : Arrays.asList("S3", "s3", "S3", "S 3")) {
Set<String> jarNames = extractJarNames(
FileUtils.searchJarFilesForStorage(zetaDir, type));
Assertions.assertEquals(new HashSet<>(Arrays.asList("s3.jar")), jarNames);
}
}
@Test
public void testSearchJarFilesForStorageWithNonExistentZetaDirectory() throws Exception {
Path nonExistentDir = Paths.get("/tmp/seatunnel-non-existent-" + System.nanoTime());
List<URL> urls = FileUtils.searchJarFilesForStorage(nonExistentDir, "s3");
Assertions.assertTrue(urls.isEmpty());
}
@Test
public void testSearchJarFilesForStorageWithCommonButNoStorageDir() throws Exception {
Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
Files.createDirectories(zetaDir.resolve("common"));
Path commonJar = Files.createFile(zetaDir.resolve("common").resolve("common.jar"));
Set<String> jarNames = extractJarNames(
FileUtils.searchJarFilesForStorage(zetaDir, "s3"));
Assertions.assertEquals(new HashSet<>(Arrays.asList("common.jar")), jarNames);
}
@Test
public void testSearchJarFilesForStoragePreventsPathTraversal() {
Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
// Test path traversal attempts
for (String maliciousType : Arrays.asList("../../etc", "../s3", "s3/../../etc")) {
Assertions.assertThrows(
IllegalArgumentException.class,
() -> FileUtils.searchJarFilesForStorage(zetaDir, maliciousType),
"Should reject path traversal in storage type: " + maliciousType);
}
}Rationale: Improve test coverage to ensure correct behavior under various edge cases. Issue 5: Missing @SInCE Annotation (MINOR)Location: /**
* Search Zeta storage JAR files from a split starter layout.
* ...
*/
public static List<URL> searchJarFilesForStorage(
@NonNull Path zetaDirectory, String storageType) throws IOException {Issue Description: Potential Risks:
Impact Scope:
Severity: MINOR (Does not affect functionality, but is a documentation standards issue) Improvement Suggestions: /**
* Search Zeta storage JAR files from a split starter layout.
* ...
*
* @since 3.0.0
*/
public static List<URL> searchJarFilesForStorage(
@NonNull Path zetaDirectory, String storageType) throws IOException {Rationale: Follow Apache project API documentation standards. Issue 6: Improper Log Level Usage (MINOR)Location: log.info(
"No split Zeta storage directory found for storage type '{}', scan all JAR(s) under {} instead",
normalizedStorageType,
zetaDirectory);Issue Description:
In such uncertain situations, Potential Risks:
Impact Scope:
Severity: MINOR (Does not affect functionality, but affects operations experience) Improvement Suggestions: log.warn(
"No split Zeta storage directory found for storage type '{}', " +
"falling back to scan all JAR(s) under {}. This may indicate a configuration issue " +
"or incomplete installation. Expected directory structure: {}/common and {}/{}",
normalizedStorageType,
zetaDirectory,
zetaDirectory,
normalizedStorageType);Rationale: Using appropriate log levels can help locate problems more quickly. |
eb2aec4 to
7ec3fbd
Compare
|
Hi @corgy-w, I pulled this PR locally and reviewed the Zeta storage-jar loading path against the current Local branch: What this PR fixes:
Runtime path checked: Key local findings:
Local checks performed:
Merge conclusionConclusion: can mergeBlocking items:
Non-blocking suggestions:
Overall evaluation: This is a focused and compatible improvement to the Zeta storage dependency loading path. The implementation keeps the old layout working, updates both checkpoint and IMAP storage initialization, and has green GitHub checks, so I think it is mergeable. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the update. I re-reviewed the complete latest head 037668b66893, including the new storage-specific starter layout, checkpoint/IMAP factory discovery, assembly contents, compatibility fallback, focused classloader tests, and the EN/ZH deployment documentation.
I do not see a source- or diff-integrity blocker on the current 15-file change. The latest commits preserve root-level legacy jars, include the missing Netty common dependency for OSS, and add isolated SPI discovery tests for both checkpoint and IMAP storage. The earlier test-coverage concern is resolved; the defensive null/path/classloader-lifecycle suggestions do not demonstrate a current main-path correctness failure under the trusted server configuration model.
The current Build check is still queued, so the technical verdict is source-clear / waiting CI rather than fully clear. Daniel's repository permission is read-only, so this COMMENTED review records the technical conclusion only; a write-capable maintainer may still need to complete the approval gate after CI passes.
DanielLeens
left a comment
There was a problem hiding this comment.
CI follow-up on the unchanged head: the Build that was queued during my last review has now completed with failures. The source-side verdict is still clear; the failing signal is not in this PR's storage-specific Zeta jar path.
The first hard failure is Run / Dependency licenses during its Maven install, followed by the JDK 11 unit-test and connector integration lanes failing on the same broad JDBC compilation errors (for example a duplicate AbstractJdbcRowConverter.setNullToStatementByDataType(...) and many missing generated methods/log fields): https://github.com/corgy-w/seatunnel/actions/runs/29675022325/job/88160977200. Those files are outside this PR's 15-file diff.
I also checked the four commits now ahead on dev; they are docs/E2E-only changes and do not contain a fix for this JDBC compilation failure. Therefore, simply syncing the latest dev is not currently evidenced to solve it, and I would avoid adding unrelated JDBC changes to this PR. Please rerun the failed workflow first to rule out a transient build/tooling issue. If the same clean-run compile failure reproduces, it should be handled as a baseline/CI issue rather than patched in this branch.
DanielLeens
left a comment
There was a problem hiding this comment.
Basic information
- PR title: [Improve][Zeta] Load storage-specific starter jars
- Author: corgy-w
- Link: #10618
- Base branch: dev
- State: OPEN
- Change size: +613 / -73, 15 file(s)
- Human review ready: No
- Review time: 2026-07-26T17:03:00Z
- Local branch: seatunnel-review-10618
- Local worktree: shared bare PR 10618 review store
Stable review keys
- pr_number:
10618 - base_sha:
ac7a5d9433230c58f72ec7e58240e06fec44069e - reviewed_base_sha:
ac7a5d9433230c58f72ec7e58240e06fec44069e - merge_base_sha:
ac7a5d9433230c58f72ec7e58240e06fec44069e - head_sha:
037668b66893dac95f514d9593245f4709705f91 - reviewed_head_sha:
037668b66893dac95f514d9593245f4709705f91 - technical_verdict:
blocking - github_review_event:
NOT_POSTED - human_review_ready:
false - intended_change_correctness:
blocking - diff_integrity:
pass - deletion_total:
73 - deletion_classified:
73 - deletion_unclassified:
0 - other_total:
6 - other_confirmed:
2 - other_resolved_in_current_head:
0 - other_rejected_with_same_proposition_evidence:
3 - other_not_applicable_with_reason:
1 - other_unresolved:
0 - merge_conclusion:
fix_then_merge - reviewed_at:
2026-07-26T17:03:00Z
CI, compare, and merge-gate facts
- mergeStateStatus:
BLOCKED - reviewDecision:
REVIEW_REQUIRED - mergeable_state:
blocked - mergeable:
True - rebaseable:
False - required_ci_gate:
failing - approval_gate:
pending - conflict_gate:
satisfied - merge_queue_gate:
pending - compare: status=
diverged, ahead_by=5, behind_by=52, total_commits=5, url=dev...037668b - Gate assessment: The technical verdict is kept separate from source, diff, deletion, other-finding, CI, conflict, and approval facts documented in the corresponding sections.
What problem this PR solves
- User pain: Checkpoint/IMAP storage backends need starter-specific JARs, while global loading creates dependency conflicts.
- Fix approach: Package storage starter directories, resolve an isolated classloader from configuration for SPI discovery, and retain root legacy-JAR fallback.
- One-line summary: Storage isolation is directionally sound, but the config-derived plugin directory can currently escape starter/zeta.
- Before: All storage JARs lived in global lib where OSS/Netty and other dependencies could conflict.
- After: Each storage type isolated-loads from starter/zeta/{type}; an unvalidated type can point outside the root.
1. Code-change review
1.1 Core logic and real call/execution chain
- Behavior before: All storage JARs lived in global lib where OSS/Netty and other dependencies could conflict.
- Behavior after: Each storage type isolated-loads from starter/zeta/{type}; an unvalidated type can point outside the root.
- Normal-path hit:
conditional— Zeta checkpoint/IMAP config → FileUtils storage directory → isolated URLClassLoader/context → storage SPI factory → persistence.
Changed files, classes, and methods
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:60-95CheckpointService storage loader— Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-140searchJarFilesForStorage— The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120FileMapStore.init— IMAP properties use the same resolver/loader to discover IMapStorage SPI.
Effective prerequisites
- Effective when the storage type has a matching starter directory or legacy-root JARs.
Conditions where the change does not apply
- Missing type uses legacy layout; malformed type can currently escape and is blocking.
Complete execution chain
1. seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:60-95 -> CheckpointService storage loader [lifecycle]
Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.
Side effect: Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.
2. seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-140 -> searchJarFilesForStorage [method_call]
The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.
Side effect: The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.
3. seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120 -> FileMapStore.init [lifecycle]
IMAP properties use the same resolver/loader to discover IMapStorage SPI.
Side effect: IMAP properties use the same resolver/loader to discover IMapStorage SPI.
- Recovery, exception, async, serialization, and concurrency paths: Loaders share the master/map lifecycle and checkpoint/FileMapStore persistence runs through isolated SPI instances.
Multi-table Sink Writer contract audit
- Applicable:
false - Sink implements SupportMultiTableSink:
Not reported by GitHub - createWriter returns the required subclass:
Not reported by GitHub - optionRule contains the replica option:
Not reported by GitHub - Evidence: Not applicable because this PR adds no SupportMultiTableSinkWriter implementation.
1.2 Compatibility impact
- Classification:
fully_compatible(fully compatible) - API: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- SPI: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Configuration: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Defaults: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Protocol and serialization: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Checkpoint/restore: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Historical behavior: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
- Migration guidance: No migration is needed for a fully compatible conclusion; otherwise follow the precise formal finding.
- Incompatible-changes documentation: Compatibility was checked against the current diff; any required migration documentation is represented as a formal blocker.
1.3 Performance and side effects
- CPU: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Memory: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- GC: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Network: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Lock contention: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Concurrency safety: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Retry: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Idempotency: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Resource release: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
- Overall: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
1.4 Error handling and logging
- Exception propagation: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
- Context: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
- Log levels: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
- Sensitive information: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
- Overall: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
1.5 Diff integrity, deletion ledger, and scope audit
- intended_change_correctness:
blocking - diff_integrity:
pass - deletion_ledger: total=
73, classified=73, unclassified=0 - Reconciliation: 73 = 73 + 0
Deletion, rename, and disappeared-capability ledger
deletion-001..deletion-016| count=16|deletion|intended_change|docs/en/engines/zeta/hybrid-cluster-deployment.md(old line 348 .. old line 392) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-017..deletion-032| count=16|deletion|intended_change|docs/en/engines/zeta/separated-cluster-deployment.md(old line 309 .. old line 352) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-033..deletion-042| count=10|deletion|intended_change|docs/zh/engines/zeta/hybrid-cluster-deployment.md(old line 344 .. old line 353) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-043..deletion-052| count=10|deletion|intended_change|docs/zh/engines/zeta/separated-cluster-deployment.md(old line 314 .. old line 323) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-053| count=1|deletion|intended_change|seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java(old line 52) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-054..deletion-059| count=6|deletion|intended_change|seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java(old line 54 .. old line 59) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.deletion-060..deletion-073| count=14|deletion|intended_change|seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java(old line 58 .. old line 71) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
Scope and base-drift items
-
No out-of-scope hunk, stale-base change, or merge artifact requires a separate ledger entry.
-
Out-of-scope hunk conclusion: All 15 files belong to storage packaging/loading/tests/bilingual docs.
-
Stale-base conclusion: No unrelated hunk, file deletion, or rollback exists; containment is an in-scope design blocker.
-
Merge-artifact conclusion: GitHub reports no conflict and the diff has no artifact.
2. Code-quality assessment
2.1 Code conventions, title format, and comments
- Title format: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.
- Code conventions: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.
- Comment completeness: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.
2.2 Test coverage and stability
- Unit tests:
covered— Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases. - Component tests:
covered— Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases. - Engine integration tests:
covered— Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases. - E2E:
missing— Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases. - Regression tests:
missing— Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases. - Stability classification:
risk
Test-stability evidence
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120- Trigger: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.
- Probability basis: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.
- Analysis: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.
Missing scenarios
- The blocking fix must add traversal/absolute/symlink containment tests; other null/partial coverage can join the same batch.
2.3 Documentation
- User-visible change:
true - docs/en: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
- docs/zh: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
- Examples: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
- Configuration truth: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
- URL truth: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
2.4 Local-validation boundary and GitHub CI evidence
- Local boundary: This round used complete static source, diff, call-chain, discussion, CI, and merge-gate evidence only; no local compilation, UT, IT, E2E, packaging, Docker, service startup, or real job was executed.
Local execution boundary
compilation:not_executed— Not executed; current-head GitHub CI is the runtime evidence.unit_tests:not_executed— Not executed.integration_tests:not_executed— Not executed.e2e:not_executed— Not executed.packaging:not_executed— Not executed.docker:not_executed— Not executed.service_start:not_executed— Not executed.real_job:not_executed— Not executed.
Actually executed review commands
git diff --stat ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91- Result:
passed - Explanation: Confirmed 15 files and +613/-73.
- Result:
git diff --name-status ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91- Result:
passed - Explanation: Completed the file-scope and deletion/rename audit.
- Result:
git diff --unified=0 ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91- Result:
passed - Explanation: Completed the current-head hunk-by-hunk review.
- Result:
git diff --check- Result:
passed - Explanation: The static whitespace check passed.
- Result:
Required checks
- required_checks_status:
AVAILABLE Build| workflow=On pull request update| job=Not reported by GitHub| state=FAILURE| bucket=fail| conclusion=FAILURE| https://github.com/apache/seatunnel/runs/88160818745
Complete status-check rollup
Notify test workflow| workflow=On pull request update| job=Not reported by GitHub| state=COMPLETED| bucket=pass| conclusion=SUCCESS| https://github.com/apache/seatunnel/actions/runs/29675022426/job/88160807175labeler| workflow=Pull Request Labeler| job=Not reported by GitHub| state=COMPLETED| bucket=pass| conclusion=SUCCESS| https://github.com/apache/seatunnel/actions/runs/29675022445/job/88160807164Build| workflow=On pull request update| job=Not reported by GitHub| state=COMPLETED| bucket=fail| conclusion=FAILURE| https://github.com/apache/seatunnel/runs/88160818745
3. Architecture assessment
3.1 Solution type: precise fix / workaround / long-term design
- Type:
long_term_design - Assessment: Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.
3.2 Maintainability
Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.
3.3 Extensibility
Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.
3.4 Historical-version compatibility
Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.
4. Disposition ledger for findings from other reviewers
- total=
6, confirmed=2, resolved_in_current_head=0 - rejected_with_same_proposition_evidence=
3, not_applicable_with_reason=1, unresolved=0 - Reconciliation: 6 = 2 + 0 + 3 + 1 + 0
issuecomment-4083439262-null-config — DanielCarter-stack
- Original proposition: Chained checkpoint-storage config access has an NPE risk.
- Location: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:73-89
- Thread: #10618 (comment)
- Current-head evidence: CheckpointConfig.storage and storagePluginConfig are initialized by non-null defaults and missing type enters legacy fallback.
- Disposition:
rejected_with_same_proposition_evidence - Daniel disposition: Rejected with same-proposition lifecycle/config evidence.
issuecomment-4083439262-loader-close — DanielCarter-stack
- Original proposition: URLClassLoaders leak because they are not explicitly closed.
- Location: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:72-90; seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:77-115
- Thread: #10618 (comment)
- Current-head evidence: Loaders live for the master-server or map-storage lifecycle, not per record/retry; immediate close can break lazy class/resource loading.
- Disposition:
rejected_with_same_proposition_evidence - Daniel disposition: Rejected with same-proposition lifecycle/config evidence.
issuecomment-4083439262-traversal — DanielCarter-stack
- Original proposition: Unvalidated storage.type permits ../ traversal outside starter/zeta and dynamic JAR loading.
- Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131
- Thread: #10618 (comment)
- Current-head evidence: The value is only trimmed/lowercased before resolve, with no normalized containment or allowlist, followed by recursive FOLLOW_LINKS walking.
- Disposition:
confirmed - Daniel disposition: Daniel +1; confirmed and aggregated as Issue 1.
- Aggregated finding:
问题 1
issuecomment-4083439262-tests — DanielCarter-stack
- Original proposition: Tests omit null/empty/nonexistent/traversal/invalid/symlink boundaries.
- Location: seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java
- Thread: #10618 (comment)
- Current-head evidence: Current tests cover case/trim/split/legacy/mixed layouts but not traversal, invalid identifiers, or containment/symlink proof.
- Disposition:
confirmed - Daniel disposition: Daniel +1; confirmed and aggregated as Issue 2.
- Aggregated finding:
问题 2
issuecomment-4083439262-since — DanielCarter-stack
- Original proposition: The new public utility needs an @SInCE tag.
- Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-90
- Thread: #10618 (comment)
- Current-head evidence: Repository FileUtils public utilities have no per-method @SInCE convention and this method already has complete JavaDoc.
- Disposition:
not_applicable_with_reason - Daniel disposition: Repository convention does not require this item.
issuecomment-4083439262-warn — DanielCarter-stack
- Original proposition: Legacy-layout fallback should log WARN rather than INFO.
- Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:127-131
- Thread: #10618 (comment)
- Current-head evidence: Fallback is a documented backward-compatible supported path rather than a misconfiguration.
- Disposition:
rejected_with_same_proposition_evidence - Daniel disposition: Rejected with same-proposition lifecycle/config evidence.
5. Formal findings
问题 1 — storage.type can escape starter/zeta during plugin discovery
- Source reviewer: DanielCarter-stack
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131 - Thread: #10618 (comment)
- Problem and real execution path: searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment. searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment.
- Current-head evidence: searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment.
- Trigger condition: storage.type is ../other-dir, an absolute path, or a symlink resolving to a JAR directory outside the root.
- Potential impact: The engine plugin loader scans and loads JARs outside the intended starter subtree, making startup depend on unrelated filesystem content and crossing the isolation boundary.
- Best actionable fix: Allow only one supported identifier for storage.type; compare normalized absolute resolved.startsWith(root), and reject escaping symlinks, absolute paths, and separators.
- Severity:
high - Merge gate:
blocking - Current-head disposition:
confirmed_in_current_head - Already raised by another reviewer:
true - Other finding ID:
issuecomment-4083439262-traversal
问题 2 — Plugin-path containment lacks a focused regression matrix
- Source reviewer: DanielCarter-stack
- Location:
seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java:155-217 - Thread: #10618 (comment)
- Problem and real execution path: The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape. The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape.
- Current-head evidence: The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape.
- Trigger condition: A future path-resolution change or malformed engine configuration.
- Potential impact: The plugin-loading boundary can regress without a test signal.
- Best actionable fix: Use temporary directories to cover null/blank/nonexistent, separator/absolute/traversal, normalized containment, and escaping symlinks.
- Severity:
low - Merge gate:
non_blocking - Current-head disposition:
confirmed_in_current_head - Already raised by another reviewer:
true - Other finding ID:
issuecomment-4083439262-tests
6. Findings summary
| ID | Finding | Location | Severity | Merge gate |
|---|---|---|---|---|
| 问题 1 | storage.type can escape starter/zeta during plugin discovery | seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131 | high | blocking |
| 问题 2 | Plugin-path containment lacks a focused regression matrix | seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java:155-217 | low | non_blocking |
7. Merge conclusion
Conclusion:can merge after fixes
Blocking items
storage-path-containment[source] (问题 1): The config-derived plugin path can escape starter/zeta.
Non-blocking recommendations
问题 2: Use temporary directories to cover null/blank/nonexistent, separator/absolute/traversal, normalized containment, and escaping symlinks.
Overall assessment
Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.
Better alternative implementation and trade-offs
- Alternative: Global lib is simpler but preserves dependency conflicts; a validated contained starter path is the correct trade-off.
- Trade-offs: Global lib is simpler but preserves dependency conflicts; a validated contained starter path is the correct trade-off.
8. GitHub publication and reply readback
- Publication event:
COMMENT - Publisher identity:
DanielLeens(repository permissionREAD) - Reviewed commit:
037668b66893dac95f514d9593245f4709705f91 - This complete report is the submitted GitHub Review body. Its immutable review ID, URL, state, and submission time are verified from the GitHub API immediately after creation and retained in the local bilingual evidence.
- Any precise line-thread replies are separate GitHub objects and are likewise verified individually.
Closes the blocking finding from review: storage.type is user
configuration, and searchJarFilesForStorage resolved it directly
against the starter/zeta directory, so a path-shaped value
("../other-dir", an absolute path) or a subdirectory symlinked outside
the root made the engine plugin loader scan and load JARs from
unrelated filesystem locations, crossing the starter isolation
boundary.
- storage.type must now match [a-z0-9_-]+ after trim/lowercase; every
legitimate value (hdfs, s3, oss, ...) passes unchanged, and anything
path-shaped fails closed to the legacy whole-root scan, which never
leaves zetaDirectory. The rejection is logged with the offending
value.
- Both the common/ and the storage-specific subdirectory are only
scanned when their real path (symlinks resolved) is still inside the
root's real path, because the JAR walk follows links; escaping
directories are skipped with a warning naming the resolved target.
- Added the regression matrix the review asked for: traversal value,
absolute-path value, and an escaping-symlink subdirectory (POSIX
only) all assert the escaped JAR is never loaded while in-root
loading keeps working.
Behavior for every valid configuration is unchanged: same directories
scanned, same fallback to the legacy layout when no split directory
exists.
Four deployment-doc conflicts: dev enriched the legacy lib/-layout notices with the new seatunnel-shade jar names and explanations while this branch rewrote the same notices for the split starter/zeta layout. Resolved by keeping this branch's layout statement (jars ship in starter/zeta/common plus the storage-specific directory) and folding in dev's current shaded-jar naming, explanation, and jar lists -- this branch's old text referenced the pre-rename jar names, which would have been stale documentation.
|
Closed out the blocking finding from the 2026-07-26 review, took the non-blocking test suggestion with it, and synced the branch with current The containment fix (
Behavior for every valid configuration is unchanged: same directories scanned, same legacy fallback when no split layout exists. Regression matrix added (the review's non-blocking ask): traversal value, absolute-path value, and an escaping-symlink subdirectory (POSIX-only — symlink creation needs privileges on Windows runners) all assert the escaped JAR is never loaded while in-root loading keeps working. Dev sync: four deployment-doc conflicts — dev had enriched the legacy Fresh CI is running on the new head. |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Zeta's checkpoint storage and IMAP persistence backends (S3, OSS, etc.) each pull in their own
Hadoop/SDK dependencies. Before this PR, those jars had to live in the global lib/ classpath,
where OSS's Aliyun SDK stack (and its Netty version) could collide with other storage
implementations' dependencies loaded into the same classloader. The fix packages storage-specific
jars under starter/zeta/{common,s3,oss} and has CheckpointService / FileMapStore build an
isolated URLClassLoader scoped to the configured storage.type before doing SPI discovery,
falling back to the legacy whole-directory scan when the split layout isn't present. One-sentence
summary: storage dependency isolation for Zeta's checkpoint/IMAP storage backends, with full
backward compatibility for the flat starter/zeta layout.
This is a NEED_REREVIEW. Daniel's last review (2026-07-26, head 037668b66893) confirmed one
HIGH-severity finding raised by another reviewer (DanielCarter-stack): storage.type was
resolved directly against the starter/zeta root with no containment check, so a path-shaped value
(../other-dir, an absolute path, or an escaping symlink) could make the engine plugin loader
scan and load JARs from outside the intended subtree. The head has since moved to 77afe1b29dee
(today, davidzollo's "dev sync + containment fix" commit), so this is a full fresh re-review of
the entire current diff, not just the incremental change.
1. Code Change Review
1.1 Core Logic Analysis
Before (as of the July 26 review): FileUtils.searchJarFilesForStorage resolved
zetaDirectory.resolve(normalizedStorageType) with only trim()/toLowerCase() applied, then
walked it with FOLLOW_LINKS. "../other-dir", an absolute path, or a subdirectory that was a
symlink to somewhere outside starter/zeta would all be scanned and their JARs loaded into the
engine.
After (current head, seatunnel-common/.../FileUtils.java:36-137):
private static final Pattern STORAGE_TYPE_PATTERN = Pattern.compile("[a-z0-9_-]+");
private static boolean isContainedDirectory(Path directory, Path rootRealPath) throws IOException {
if (!Files.isDirectory(directory)) return false;
Path realPath = directory.toRealPath();
if (!realPath.startsWith(rootRealPath)) {
log.warn("Ignoring storage jar directory {} because it resolves to {} outside {}", ...);
return false;
}
return true;
}
public static List<URL> searchJarFilesForStorage(@NonNull Path zetaDirectory, String storageType) {
...
if (!STORAGE_TYPE_PATTERN.matcher(normalizedStorageType).matches()) {
log.warn("Ignoring illegal storage type '{}' ...: only [a-z0-9_-] names are allowed. "
+ "Falling back to scanning {}", storageType, zetaDirectory);
return searchJarFiles(zetaDirectory);
}
Path zetaRealPath = zetaDirectory.toRealPath();
Path commonDir = zetaDirectory.resolve("common");
if (isContainedDirectory(commonDir, zetaRealPath)) { ... jars.addAll(searchJarFiles(commonDir)); }
Path storageDir = zetaDirectory.resolve(normalizedStorageType);
if (isContainedDirectory(storageDir, zetaRealPath)) { ... jars.addAll(searchJarFiles(storageDir)); }
...
}Key findings on the current head:
storage.typeis now validated against[a-z0-9_-]+(whole-string match) before it is ever
used to build a path — any separator,.., drive/scheme prefix, or absolute-path shape fails
the regex and falls back to the legacy whole-directory scan, which never leaveszetaDirectory.- Even a value that passes the regex is still subject to
isContainedDirectory, which resolves
the real path (symlinks included, since the JAR walk usesFOLLOW_LINKS) and requires
realPath.startsWith(rootRealPath). This closes the symlink-escape vector specifically, not
just the string-shaped traversal vector. - I re-derived the exploit scenario from the July 26 finding by hand:
storage.type = "../etc"
now fails the regex (contains/and.) → legacy scan ofzetaDirectoryonly. An absolute
path asstorage.typealso fails the regex (contains/). A symlink nameds3under
starter/zetapointing outside the root passes the regex (it'ss3) but fails
isContainedDirectory'sstartsWithcheck → skipped with aWARNlog naming the resolved
target. All three vectors from the confirmed finding are closed by independent, overlapping
checks (regex first, containment second), which is a reasonable defense-in-depth structure
rather than relying on a single guard. - I confirmed this isn't just theoretical: the CI run for the current head (see 2.2) executed the
updatedFileUtilsTest— including the new traversal, absolute-path, and symlink-escape
regression tests — and all 10 test cases in that class passed onubuntu-latest/JDK 8.
Complete runtime path (retraced from SeaTunnelServer on the current head, not assumed from
the prior review):
1. seatunnel-engine-server/.../SeaTunnelServer.java:196-209 -> startMaster() [lifecycle, master-only, called once per process]
Invoked once from init(), either directly (MASTER role) or as part of the MASTER_AND_WORKER
branch. Not part of any retry loop; this is a one-shot startup step.
2. seatunnel-engine-server/.../CheckpointService.java:171-207 -> CheckpointService(config) [constructor]
Delegates to CheckpointService(config, Common.appStarterDir().resolve("zeta")).
Reads config.getStorage().getStoragePluginConfig().get("storage.type") (see 1.3 for null-safety).
3. seatunnel-common/.../FileUtils.java:80-137 -> searchJarFilesForStorage(zetaDirectory, storageType)
Validates storageType, resolves common/ + <type>/ under containment, falls back to legacy scan.
4. seatunnel-engine-server/.../CheckpointService.java:188-206 -> URLClassLoader + TemporaryClassLoaderContext
If storageJars is non-empty, wraps the current context classloader; otherwise keeps it unchanged.
FactoryUtil.discoverFactory(...) runs the SPI lookup with the context classloader temporarily
swapped, then TemporaryClassLoaderContext.close() restores the original context classloader on
the same thread (seatunnel-common/.../TemporaryClassLoaderContext.java:31-52, unchanged by this
PR — this is the engine's existing, pre-existing swap-and-restore utility).
5. Parallel path: Hazelcast IMap persistence -> FileMapStoreFactory.newMapStore() [seatunnel-engine-server/.../FileMapStoreFactory.java:29]
-> new FileMapStore() -> FileMapStore.init(instance, properties, mapName) [seatunnel-engine-server/.../FileMapStore.java:54-56]
-> init(..., Common.appStarterDir().resolve("zeta")) [FileMapStore.java:60-110] follows the same
searchJarFilesForStorage -> optional URLClassLoader -> TemporaryClassLoaderContext -> FactoryUtil.discoverFactory
sequence, once per persisted IMap name at master startup.
6. Later: CheckpointService.getLatestCheckpoint() / FileMapStore.store()/load() use the already-
constructed checkpointStorage / mapStorage instances — no further classloading occurs on the
record hot path.
Both entry points (new CheckpointService(...) and FileMapStoreFactory.newMapStore()) are
called exactly once per process lifetime at master startup — I grepped the whole pr-10618 tree
for both call sites and found no other callers besides the two @VisibleForTesting test
constructors. This confirms the "startup/init only, outside the record hot path" characterization
from the prior review still holds on the current diff.
1.2 Compatibility Impact
Fully compatible.
- Legacy flat-
starter/zetainstalls:searchJarFilesForStoragefalls back to
searchJarFiles(zetaDirectory)(unchanged, recursive, unbounded-depth) whenever the split
common/+<type>/layout isn't detected — same behavior as before this PR existed. - Mixed layout (split dirs present but with legacy jars still at zeta root): root-level jars
(searchJarFiles(zetaDirectory, 1), depth-limited so it doesn't re-walkcommon//<type>/)
are still added, so an in-place upgrade that hasn't fully adopted the split layout keeps
working — verified bytestSearchJarFilesForStorageKeepsLegacyRootJarsInMixedLayout. - Assembly changes (
seatunnel-dist/src/main/assembly/assembly-seatunnel-bin{,-ci}.xml) are
purely additive: the existing/libdependencySets forseatunnel-shade-hadoop3-uberand
seatunnel-shade-hadoop-awsare untouched; three new dependencySets add jars under
/starter/zeta/{common,s3,oss}without removing anything from/lib. seatunnel-dist/pom.xmlonly adds newprovided-scope dependencies (hadoop-aliyun,
aliyun-sdk-oss,jdom,netty-buffer) — no version bumps or removals of existing
dependencies.- Config/option semantics: no
Optionwas added, renamed, or had its default changed;
storage.typewas already user-supplied plugin config consumed byFactoryUtil.discoverFactory. - Checkpoint/restore format: unaffected — this PR only changes how the
CheckpointStorage/
IMapStorageimplementation class is located, not the serialized checkpoint/IMAP data format.
1.3 Performance / Side-Effect Analysis
- CPU/IO:
Files.walkovercommon/+<type>/(bounded to those two subtrees) plus a
depth-1 scan of the root — all filesystem-bound, startup-only, not on the record hot path. - Classloader lifecycle:
new CheckpointService(...)and eachFileMapStore.init(...)run
exactly once per process (see runtime path above), so there is no unbounded accumulation of
URLClassLoaderinstances over the process lifetime. TheURLClassLoaderis never explicitly
close()d, but sincecheckpointStorage/mapStoragehold instances of classes loaded by it for
the entire life of the service, an earlyclose()would not free anything the JVM could
otherwise reclaim while those instances are in use — the earlier "MAJOR: URLClassLoader not
closed" suggestion (from the initialDanielCarter-stackcomment) does not apply to a
singleton-at-startup lifecycle; it would matter if these constructors were invoked repeatedly
(e.g., per record or per retry), which I confirmed via the call-site grep is not the case here. - TOCTOU note (non-blocking): there is a theoretical gap between
isContainedDirectory's
toRealPath()/startsWith()check and the laterFiles.walkinsearchJarFiles, but exploiting
it requires local filesystem write access to swap a symlink understarter/zetabetween the two
calls — an attacker with that capability could already drop a malicious JAR directly under
starter/zeta/commonwithout touchingstorage.typeat all, so this doesn't cross a real
trust boundary given the existing "trusted server configuration/filesystem" model the engine
already assumes elsewhere (e.g., connector plugin loading).
1.4 Error Handling and Logging
- Illegal
storage.type(fails the[a-z0-9_-]+regex) →log.warnnaming the offending value
and the fallback target. Escaping symlink →log.warnnaming the resolved real path and the
root. Benign fallback (no split layout present, e.g. a legacy install) →log.info. This
differentiation is an improvement on the initial PR version and addresses the spirit of the
original "log level" nitpick (illegal/anomalous input is now WARN; a supported legacy path is
INFO). FileMapStore.init's existingcatch (RuntimeException e)around factory discovery/creation
(withlog.errorincludingmapNameandstorageType) is preserved verbatim around the new
classloader-wrapped call — no exception context was dropped by wrapping it in
TemporaryClassLoaderContext.CheckpointService's constructor is annotated@SneakyThrows(pre-existing pattern in this
class, unchanged) — anIOExceptionfromsearchJarFilesForStorage(e.g., permission-denied
readingcommon/) at master startup will not be silently swallowed; it propagates and would
fail cluster initialization, which is intentional fail-fast behavior for a storage the whole
cluster's checkpoint mechanism depends on.
Issue 1: dev-baseline compile break makes the current head's own new engine-server tests
unverified by CI (currently red for an unrelated reason)
- Location:
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/event/JobStateEventTest.java:165 - Problem: The fork CI run for the current head (
77afe1b29dee) fails at
maven-compiler-plugin:testCompilefor moduleseatunnel-engine-serverwithcannot find symbol: variable FAILED_JOB_EVENT_TIMEOUT_SECONDS. I traced this todevcommit033612bfd
("[Fix][E2E] Address follow-up review issues for CI stabilization (#11097)", authored by
davidzollo, merged 2026-08-23 22:25, i.e. hours before this PR's fresh dev-sync this morning).
That commit renamedJobStateEventTest's localFAILED_JOB_EVENT_TIMEOUT_SECONDSfield to a
static import ofCheckpointErrorRestoreEndTest.RESTORE_TO_FAILED_TIMEOUT_SECONDSand updated
one usage (line ~91) but missed a second usage at line 165, which still references the deleted
field name. I confirmedgit diff dev...pr-10618for this file is empty (byte-identical to
devHEAD) and that this PR's merge-base withdevisdevHEAD (406c66789) — this is
purely adev-side bug this PR inherited via its own dev-sync commit this morning, not
something introduced by PR #10618's 15-file diff. - Potential impact for this PR specifically: because the broken test class lives in the same
Maven module (seatunnel-engine-server) as this PR's two new tests
(CheckpointServiceStorageClassLoaderTest,FileMapStoreTest), the module fails to
test-compile at all, so those new isolation tests have not actually executed in this CI run —
I grepped the full CI log and found noCheckpointServiceStorageClassLoaderTestor
FileMapStoreTestoutput anywhere.FileUtilsTest(inseatunnel-common, a different module)
did compile and run, and all 10 of its cases — including the traversal/absolute/symlink
regression tests — passed. - Best actionable fix: this is not something to patch inside PR #10618 (per the "don't add
unrelated changes" guidance from Daniel's own July 19 comment on this same PR). It needs either
a separate fix ondev(restore the local field, or fix the second usage to reference
RESTORE_TO_FAILED_TIMEOUT_SECONDS) followed by a rebase of this branch, or simply waiting for
devto be fixed and re-syncing/rerunning CI. Once that lands, this PR's own new engine tests
need to actually go green before merge. - Severity: Medium (blocks confirmation that this PR's own new tests pass, but is not a defect
in this PR's diff). - Raised by another reviewer: No.
2. Code Quality Assessment
2.1 Coding Standards
FileUtils.searchJarFilesForStoragehas complete Javadoc (@param,@return,@throws).
isContainedDirectoryand theSTORAGE_TYPE_PATTERNconstant both have explanatory Javadoc
covering why (not just what) — consistent with the "explain why, not what" comment standard.CheckpointService's package-private@VisibleForTestingconstructor andFileMapStore's
package-private@VisibleForTestingoverload both have a one-line Javadoc explaining their
test-only purpose.- No
@sincetag on the new publicFileUtils.searchJarFilesForStoragemethod — I confirmed via
git grepthat no method inseatunnel-common/src/main/java/.../FileUtils.java(or elsewhere
inseatunnel-common) carries an@sincetag, so this is not a repository convention being
skipped; the earlier ask for it does not apply here. - New test classes (
CheckpointServiceStorageClassLoaderTest,FileMapStoreTestadditions,
FileUtilsTestadditions) all have ASF license headers and class/method-level Javadoc
explaining the regression being guarded against, not just restating the method name.
2.2 Test Coverage and Test Stability
- Stability classification: Stable, with one caveat noted in Issue 1 above (this PR's two new
engine-server tests haven't executed in the current CI run due to an unrelated module-wide
compile break). seatunnel-common/.../FileUtilsTest.java(seatunnel-common/src/test/.../FileUtilsTest.java:155-278):
6 new tests cover common+storage-dir loading with mixed-case/whitespace input, legacy-layout
fallback, mixed split/legacy layout, traversal rejection ("../outside"), absolute-path
rejection, and symlink-escape rejection (@DisabledOnOs(OS.WINDOWS)with a documented reason —
symlink creation needs elevated privileges on Windows CI runners). All 10 cases in this class
ran and passed in the current CI run (ubuntu-latest, JDK 8) — direct evidence the containment
fix works, not just static-analysis confidence.CheckpointServiceStorageClassLoaderTest(new file,
seatunnel-engine-server/src/test/.../CheckpointServiceStorageClassLoaderTest.java): compiles a
throwawayCheckpointStorageFactoryimplementation into a real JAR at test time (with a
META-INF/servicesprovider entry) and places it only under the tempzeta/s3/directory, then
assertsCheckpointService's package-private constructor can discover and instantiate it. This
is a genuine end-to-end proof that the isolated classloader path reaches SPI discovery
correctly, not a mock-based approximation.FileMapStoreTestgets the equivalent addition forIMapStorageFactorydiscovery via
FileMapStore.init(...).- Missing/lower-priority (non-blocking): no test exercises the
IOExceptionpath inside
FileMapStore.init(e.g., a genuinely unreadablezetaDirectory), and there's no explicit test
for an invalid identifier that embeds a separator mid-string (e.g.,"s3/../etc") — though this
is structurally the same code path as the pure-traversal test already present (both fail the
same whole-string regex), so the marginal coverage value is low.
2.3 Documentation Updates
docs/en/engines/zeta/checkpoint-storage.mdand itsdocs/zhcounterpart both gained a new
paragraph explaining thestarter/zeta/common+starter/zeta/<type>split-loading behavior,
the legacy-scan fallback, and that COS jars are still not bundled (must be added tolib/
manually) — this last point is an accurate, useful caveat since the assembly changes in this PR
only cover S3/OSS/common, not COS.hybrid-cluster-deployment.mdandseparated-cluster-deployment.md(both languages) had their
OSS/S3 "make sure the following jars are in the lib directory" notices updated to explain that
the official binary package now copies these jars tostarter/zeta/{common,oss}/
starter/zeta/{common,s3}and that manual placement inlib/is only needed for custom builds.
I checked the EN and ZH wording side by side — they convey the same information (not a verbatim
translation, but semantically aligned), consistent with the bilingual-docs requirement.- No incompatible-changes doc entry is needed since this change is fully backward compatible (see
1.2).
3. Architectural Soundness
3.1 Elegance of the Solution: Precise fix
The regex allowlist ([a-z0-9_-]+) plus real-path containment check (isContainedDirectory) is a
standard, well-understood defense-in-depth pattern for user-supplied path segments, and it's
applied consistently to both the common/ and <type>/ resolution — not just the
storage.type-derived one. Falling back to the pre-existing legacy whole-root scan (rather than
throwing) on any rejection keeps the failure mode "less isolated than intended" instead of
"cluster fails to start," which is a reasonable choice for a fail-safe-open default in a startup
path, since the legacy scan itself never leaves zetaDirectory.
3.2 Maintainability
The two @VisibleForTesting constructor/method overloads that accept an explicit zetaDirectory
are a clean way to make CheckpointService and FileMapStore testable against a temp directory
without needing to fake Common.appStarterDir() globally — this is a good pattern other engine
tests could reuse.
3.3 Extensibility
Adding a new storage type only requires adding a new assembly dependencySet targeting
/starter/zeta/<type> — no code change is needed in FileUtils, CheckpointService, or
FileMapStore, since the directory name is derived directly from the storage.type config value.
3.4 Historical-Version Compatibility
Confirmed compatible for clusters upgrading in place from a version that only has the flat
starter/zeta layout (falls back to legacy scan) and for clusters mid-upgrade with a partially
split layout (mixed-layout test). No checkpoint/IMAP data format or Option contract changed.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| Issue 1 | dev-baseline compile break (unrelated to this PR) leaves this PR's own new engine-server tests unverified by the current CI run |
seatunnel-engine-server/.../event/JobStateEventTest.java:165 |
Medium |
No High or Low severity issues remain open in this PR's own diff. The previously-confirmed HIGH
finding (storage.type path-traversal/symlink-escape) and the previously-confirmed test-coverage
gap are both resolved and verified passing in the current CI run.
5. Merge Recommendation
Conclusion: Ready to merge after fixes
-
Blockers — must be fixed:
- None in this PR's own diff. The only open item (Issue 1) is a
dev-baseline break this PR
inherited via this morning's dev-sync; it needsdevfixed (or this branch rebased past a
fix) and a green CI run confirmingCheckpointServiceStorageClassLoaderTestand
FileMapStoreTestactually pass, since neither has executed successfully yet in any CI run
I could find for this head.
- None in this PR's own diff. The only open item (Issue 1) is a
-
Recommended fixes — non-blocking:
- Consider adding a test for
FileMapStore.init'sIOExceptionpath and/or an
embedded-separator invalid identifier, though the marginal value is low given the existing
regex-based coverage.
- Consider adding a test for
Overall assessment: This is a solid, backward-compatible improvement to Zeta's storage
dependency isolation. The HIGH-severity path-containment issue from the prior round has been
fixed correctly and thoroughly (regex allowlist + real-path containment, covering both the
string-traversal and symlink-escape vectors independently), and the fix is backed by passing
regression tests observed in the current CI run, not just static reasoning. The only remaining
gap is procedural, not architectural: get a clean CI run (after the unrelated dev-side
JobStateEventTest.java break is resolved) that actually exercises this PR's two new
engine-server tests before merging.
Alternative implementation note: none — the split-directory-plus-isolated-classloader design
is the right trade-off here; keeping everything in the global lib/ (the pre-PR state) is simpler
but is exactly the dependency-conflict problem this PR sets out to fix.
SEZ9
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head 77afe1b29dee.
What this PR fixes
- User pain: Zeta checkpoint/IMAP storage jars for S3 and OSS all live in
lib/, so their Hadoop/SDK stacks are loaded into one classloader and collide with each other and with connector dependencies. - Fix approach: Package storage jars into
starter/zeta/commonplus per-storage subdirectories (s3,oss) in both dist assemblies, and addFileUtils.searchJarFilesForStoragethat loadscommon/plus the directory matchingplugin-config.storage.type(with pattern validation, symlink containment viatoRealPath, root-level legacy-jar pickup, and a whole-directory fallback for the legacy layout), with EN/ZH doc updates. - One-line summary: The split-layout loading, tests, and docs are in place, but the containment guard only checks the top-level directory (nested symlinks still escape via
FOLLOW_LINKS), the empty/illegal storage.type fallbacks silently re-widen the scan to the whole tree (contradicting the "fail closed" comment and the docs' "always loads common" claim), a missing storage dir is silently ignored deferring failure to a runtime ClassNotFoundException, and unguardedtoRealPath()calls can abort engine startup.
Runtime chain I rechecked
SeaTunnelServer startup (checkpoint / IMAP storage initialization)
-> CheckpointService storage bootstrap reads plugin-config.storage.type and resolves the starter dir CheckpointService.java:63
-> Common.appStarterDir().resolve("zeta")
-> FileUtils.searchJarFilesForStorage(zetaDirectory, storageType) FileUtils.java:119
-> null/empty storageType -> searchJarFiles(zetaDirectory) [legacy whole-tree scan] FileUtils.java:128
-> STORAGE_TYPE_PATTERN.matcher(normalizedStorageType) -> on mismatch, falls back to searchJarFiles(zetaDirectory) FileUtils.java:135
-> zetaDirectory.toRealPath() [can throw IOException on dangling symlink] FileUtils.java:146
-> isContainedDirectory(commonDir, zetaRealPath) FileUtils.java:88
-> Files.isDirectory / directory.toRealPath() / realPath.startsWith(rootRealPath)
-> searchJarFiles(commonDir) FileUtils.java:49
-> Files.walk(directory, maxDepth, FileVisitOption.FOLLOW_LINKS) [follows nested symlinks past the containment check] FileUtils.java:59
-> isContainedDirectory(storageDir, zetaRealPath) -> searchJarFiles(storageDir) FileUtils.java:157
-> splitLayoutDetected -> searchJarFiles(zetaDirectory, 1) [root-level legacy jars] FileUtils.java:164
-> returned URLs added to the storage classloader used to instantiate the CheckpointStorage / IMAP persistence factory
Findings
Issue 1: Once the split layout is detected, jars in non-matching subdirectories of starter/zeta are silently dropped — an upgrade regression for users who nested custom storage jars (e.g. COS) under starter/zeta
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:163 - Why it matters: - Root cause: when
splitLayoutDetectedis true, the method loads onlycommon/, the directory matching the normalized storage type, and root-level jars at depth 1 (searchJarFiles(zetaDirectory, 1)). The pre-existing behavior was a full recursive scan ofstarter/zeta, so any other subdirectory (e.g. a user-createdstarter/zeta/cos/when storage.type iscosbut the packaged dirs are onlycommon/s3/oss, or an arbitrarystarter/zeta/extra-libs/folder) that used to be picked up is now silently skipped. - Impact: since the official dist always ships
common/, the split-layout branch is always taken after upgrade, and jars users nested under other subdirectories vanish from the storage classpath with no warning, surfacing later asClassNotFoundExceptionin the storage factory. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:155-158 Path storageDir = zetaDirectory.resolve(normalizedStorageType); if (isContainedDirectory(storageDir, zetaRealPath)) { splitLayoutDetected = true; jars.addAll(searchJarFiles(storageDir)); - Suggested fix: After upgrade the official dist always contains
common/, so this branch is always taken — and it only seescommon/, the matched storage dir, and root-level jars at depth 1. Any other subdirectory a user previously created understarter/zeta(previously picked up by the full recursive scan) is now silently skipped, surfacing later asClassNotFoundExceptionin the storage factory. Please log a WARN listing the skipped subdirectories here so operators can diagnose the layout change, and mention it in the release/upgrade notes. - Severity: Medium
*Issue 2: Symlink containment is only enforced at the top-level directory; the JAR walk still follows nested symlinks (and symlinked .jar files) out of the starter/zeta root, contradicting the isContainedDirectory guarantee
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:152 - Why it matters: - Root cause:
isContainedDirectoryresolves only the top-levelcommon/or<storage-type>/directory viatoRealPath(), but the subsequent scan delegates tosearchJarFiles(directory), which walks withInteger.MAX_VALUEdepth andFileVisitOption.FOLLOW_LINKS(FileUtils.java:51, :59). A symlinked subdirectory insidecommon/(e.g.common/deps -> /opt/attacker), or a symlinked file namedevil.jaranywhere in the tree — including the depth-1 root scan at line 163 — resolves outsidezetaRealPathand is still loaded. - Impact: jars outside the starter/zeta root end up in the engine classloader, which is exactly the escape the Javadoc at lines 84-87 claims this method prevents.
- Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:59 try (Stream<Path> paths = Files.walk(directory, maxDepth, FileVisitOption.FOLLOW_LINKS)) {;seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:152 jars.addAll(searchJarFiles(commonDir));;seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:163 jars.addAll(searchJarFiles(zetaDirectory, 1)); - Suggested fix:
isContainedDirectoryonly validates the top-level directory, but this call walks it withFOLLOW_LINKSat unlimited depth (see line 59). A nested symlink such ascommon/deps -> /opt/elsewhere, or a symlinkedevil.jarfile (including in the depth-1 root scan at line 163), still resolves outsidezetaRealPathand gets loaded into the engine classloader — exactly the escape the javadoc at lines 84-87 says this method prevents. Please enforce containment per jar: inside the walk, resolve each candidate withpath.toRealPath()and skip anything that doesn'tstartsWith(zetaRealPath)(or run the storage-layout walk withoutFOLLOW_LINKS). - Severity: Medium
Issue 3: An invalid storage.type silently widens the scan to the entire starter/zeta tree; the "fail closed" comment is inaccurate and misconfiguration reintroduces the exact classpath-conflict problem this PR fixes
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 - Why it matters: - Root cause: when
storage.typefailsSTORAGE_TYPE_PATTERN, the code logs a warning and returnssearchJarFiles(zetaDirectory)(FileUtils.java:142), i.e. it loads jars for every storage backend (common + s3 + oss + root) into one classloader. The inline comment at line 135 calls this "Fail closed", but relative to the split layout it is the widest possible scan, not the narrowest. - Impact: an operator typo like
storage.type: S3://bucketor a copy-paste with a slash silently degrades to the whole-tree scan, reintroducing the dependency conflicts this PR is meant to fix, with only a WARN as signal. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:136 if (!STORAGE_TYPE_PATTERN.matcher(normalizedStorageType).matches()) {;seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory); - Suggested fix: Falling back to
searchJarFiles(zetaDirectory)on an illegalstorage.typeis the widest scan, not "fail closed" as the comment above states: a typo likeS3://bucketsilently loads every backend's jars into one classloader and reintroduces the dependency conflicts this PR is meant to fix, with only a WARN as signal. I'd either throw a configuration exception here (the storage factory will reject the type anyway) or narrow the fallback tocommon/+ root-level jars, and fix the comment either way. - Severity: Medium
Issue 4: Fallback paths (empty or illegal storage.type) scan the whole zeta directory, loading conflicting storage stacks (s3 + oss) into one classloader and bypassing the symlink containment check
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:128 - Why it matters: - Root cause: both the empty-type branch and the illegal-pattern branch call
searchJarFiles(zetaDirectory), which recursively walks every subdirectory. In the official split layout that meanscommon/,s3/, andoss/jars are all merged into the same classloader. - Impact: this reintroduces exactly the dependency conflicts (e.g., OSS Aliyun SDK's Netty vs other stacks) that the split layout was created to avoid — and it happens for the default case where
storage.typeis not set at all. The full recursive scan also follows symlinks with noisContainedDirectorycheck, unlike the split-layout path. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory);;docs/en/engines/zeta/checkpoint-storage.md Ifstorage.typeis empty, SeaTunnel falls back to scanning the wholestarter/zetadirectory. - Suggested fix: With the official split layout, an unset/empty
storage.typetakes this branch and recursively loadscommon/,s3/, andoss/jars into the same classloader — reintroducing the exact dependency conflicts (e.g., OSS SDK Netty versions) this PR is meant to eliminate, for what is likely the default configuration. This full scan also follows symlinks with noisContainedDirectorycheck, unlike the split path below. Whencommon/exists, could we load onlycommon/+ root-level jars here, and keep the whole-tree scan strictly for legacy layouts without acommon/directory? - Severity: Medium
Issue 5: Empty storage.type falls back to scanning the entire starter/zeta tree, loading s3 and oss jars together and reintroducing the classpath conflict the split layout is meant to eliminate
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:128 - Why it matters: - Root cause:
if (storageType == null || storageType.trim().isEmpty()) { return searchJarFiles(zetaDirectory); }short-circuits before any split-layout detection. In the official packagestarter/zeta/s3andstarter/zeta/ossnow both exist, so an unset/blank storage.type loads the AWS and Aliyun SDK stacks (including their conflicting transitive dependencies such as Netty, per the earlier review discussion on this PR) into the same storage classloader. - Impact: users who rely on the default configuration (no
storage.typeset) get every backend's jars merged together, hitting the exact dependency-conflict scenario the split layout is designed to prevent. The illegal-type fallback at line 142 has the same problem. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory); - Suggested fix: With the new dist layout,
starter/zeta/s3andstarter/zeta/ossboth ship in the official package, so this whole-tree fallback for an emptystorage.typeloads the AWS and Aliyun SDK stacks into the same classloader — exactly the dependency-conflict scenario the split layout is designed to prevent. Whencommon/exists, please restrict the empty-type path tocommon/+ root depth-1 jars, and keep the full recursive scan only for the true legacy layout (nocommon/directory). The illegal-type fallback at line 142 has the same issue. - Severity: Medium
Issue 6: toRealPath() can throw IOException (dangling symlink, TOCTOU deletion, permission error) and abort engine startup instead of failing closed as documented
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:94 - Why it matters: - Root cause:
isContainedDirectorychecksFiles.isDirectory(directory)and then callsdirectory.toRealPath(); similarlysearchJarFilesForStoragecallszetaDirectory.toRealPath()unguarded. Between the existence check andtoRealPath(), the directory can be removed, or the path can be a symlink whose target becomes unreachable, or the real-path resolution can fail due to permissions — all of which throwIOExceptionrather than returning false. - Impact: the exception propagates out of
searchJarFilesForStorageand can abortCheckpointServicebootstrap during engine startup, whereas every other invalid input in this method degrades to a warning plus a fallback scan. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:147 Path zetaRealPath = zetaDirectory.toRealPath();;seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:91-93 if (!Files.isDirectory(directory)) { return false; } - Suggested fix:
directory.toRealPath()throwsIOExceptionif the directory disappears between theFiles.isDirectorycheck and this call, or if it is a symlink with an unreachable target. That exception propagates all the way up and can abortCheckpointServicebootstrap, whereas every other invalid input in this method degrades to a warning + fallback. Please catchIOExceptionhere (and aroundzetaDirectory.toRealPath()at line 147), log a warning, and returnfalse/ fall back to the legacy scan so the method actually fails closed as its Javadoc promises. - Severity: Medium
Issue 7: Missing storage-specific directory in a split layout is silently ignored, deferring the failure to a hard-to-diagnose ClassNotFoundException at checkpoint init
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:161 - Why it matters: - Root cause: in
searchJarFilesForStorage,splitLayoutDetectedbecomes true as soon ascommon/exists. If the user configuresstorage.type: ossbut the distribution only shipscommon/ands3/(or the directory casing differs on a case-sensitive filesystem aftertoLowerCase(Locale.ROOT)normalization), the method returns only common + root-level jars with an INFO log that reads like success ("Loaded N storage JAR(s) for storage type 'oss'"). - Impact: the engine starts, and the failure surfaces much later as a
ClassNotFoundExceptionduring checkpoint storage initialization, far from the actual misconfiguration and with no startup-time signal pointing at the missing directory. - Evidence:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:156-159 if (isContainedDirectory(storageDir, zetaRealPath)) { splitLayoutDetected = true; jars.addAll(searchJarFiles(storageDir)); };seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:161-163 if (splitLayoutDetected) { // Keep root-level jars visible ... jars.addAll(searchJarFiles(zetaDirectory, 1)); - Suggested fix: When
common/exists but the directory for the configuredstorage.typedoes not (missing from the assembly, or a casing mismatch aftertoLowerCase(Locale.ROOT)on a case-sensitive FS), we still report "Loaded {} storage JAR(s) for storage type '{}'" and proceed with only common + root jars. The real failure then shows up much later as aClassNotFoundExceptionduring checkpoint storage init. Please add an explicitlog.warnhere whensplitLayoutDetectedis true but the storage-specific directory was not found, naming the expected path (starter/zeta/<type>), so the misconfiguration is visible at startup. - Severity: Medium
Issue 8: Docs lack an upgrade note for existing deployments that already have the storage jars in lib/
- Location:
docs/en/engines/zeta/hybrid-cluster-deployment.md:349 - Why it matters: - Root cause: the new notices state "You do not need to add them to
lib/again when using the packaged distribution", but this is a user-facing behavior change for people upgrading from older releases where the deployment docs explicitly told them to place these jars inlib/. Nothing tells those users whether leftover copies inlib/are harmless or must be removed. - Impact: after upgrading, the same shaded Hadoop/OSS/S3 classes can be present both on the parent classpath (
lib/) and in the new storage classloader, which can defeat the classloader isolation this PR introduces and confuse troubleshooting. - Evidence:
docs/en/engines/zeta/separated-cluster-deployment.md:311starter/zeta/commonandstarter/zeta/oss. You do not need to add them tolib/again when - Suggested fix: Older versions of this page instructed users to copy these jars into
lib/, so upgraded clusters will often have them in bothlib/and the newstarter/zeta/*directories. Please add an explicit upgrade note here: should users remove the old copies fromlib/, or is it safe to keep them? Duplicate copies on the parent classpath can defeat the classloader isolation this PR introduces. - Severity: Medium
Review conclusion
Conclusion: final approval remains pending on the previous comments
2. Remaining follow-ups
- Issue 1: Once the split layout is detected, jars in non-matching subdirectories of starter/zeta are silently dropped — an upgrade regression for users who nested custom storage jars (e.g. COS) under starter/zeta
- Issue 2: Symlink containment is only enforced at the top-level directory; the JAR walk still follows nested symlinks (and symlinked *.jar files) out of the starter/zeta root, contradicting the isContainedDirectory guarantee
- Issue 3: An invalid storage.type silently widens the scan to the entire starter/zeta tree; the "fail closed" comment is inaccurate and misconfiguration reintroduces the exact classpath-conflict problem this PR fixes
- Issue 4: Fallback paths (empty or illegal storage.type) scan the whole zeta directory, loading conflicting storage stacks (s3 + oss) into one classloader and bypassing the symlink containment check
- Issue 5: Empty storage.type falls back to scanning the entire starter/zeta tree, loading s3 and oss jars together and reintroducing the classpath conflict the split layout is meant to eliminate
- Issue 6:
toRealPath()can throw IOException (dangling symlink, TOCTOU deletion, permission error) and abort engine startup instead of failing closed as documented - Issue 7: Missing storage-specific directory in a split layout is silently ignored, deferring the failure to a hard-to-diagnose ClassNotFoundException at checkpoint init
- Issue 8: Docs lack an upgrade note for existing deployments that already have the storage jars in lib/
Thanks for the updates so far. Happy to discuss the remaining points.
|
Hi @SEZ9, thanks for the detailed follow-up pass. I independently re-read Issue 2 (nested-symlink escape via Issues 3/4/5 (empty or illegal Issue 6 (unguarded On the CI-blocking compile break I flagged in my own August 24 review ( Given the above, I'm revising my prior "no High/blocking items in this PR's own diff" conclusion: Issue 2 should be treated as a blocking item alongside getting a clean, fully-executed CI run. Issues 1/3/4/5/6/7/8 remain valid non-blocking follow-ups worth addressing in the same pass. Thanks again for the thorough re-check, @SEZ9 — this is exactly the kind of independent verification that catches what a single reviewer misses. |
Resolve the merge conflicts with dev: keep both sides' additions (imports, constants and tests) and apply the project formatter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks @corgy-w for syncing the branch with dev. I re-read the full diff and re-traced the call chain on the current head a8c899d93394. Sorry for missing one of the items below in my earlier rounds (details in Issue 2): that is on me, it is a carryover from the previous version of the diff and not something this merge introduced, and I only noticed it now because the test finally got to run in CI.
What changed since my last review: the head moved only through the merge of dev (merge commit a8c899d93394, 2026-10-05). I diffed the PR's own change set at the head I last reviewed (77afe1b29dee) against the current one: the 15 files are identical apart from shifted hunk offsets and one import line that dev now provides itself, so the author code is unchanged.
What Problem Does This PR Solve?
- User pain point: Zeta's checkpoint and IMAP storage backends (S3, OSS, ...) all put their Hadoop/SDK jars into one flat classpath, so their dependency trees (for example the OSS SDK and its Netty version) can collide with each other and with connector dependencies.
- Fix approach: Package storage jars under
starter/zeta/{common,s3,oss}and haveCheckpointService/FileMapStorebuild a scopedURLClassLoaderfromcommon/plus the directory that matchesstorage.typebefore SPI discovery, falling back to the legacy whole-directory scan when the split layout is absent. - One-sentence summary: Storage-dependency isolation for Zeta checkpoint/IMAP storage with a backward-compatible layout.
1. Code Change Review
1.1 Core Logic Analysis
Zeta server start
-> new CheckpointService(config) CheckpointService.java:64 -> :74
-> FileUtils.searchJarFilesForStorage(starter/zeta, storage.type) FileUtils.java:134
-> null/empty or illegal storage.type -> searchJarFiles(zetaDirectory) FileUtils.java:142 / :156
-> zetaDirectory.toRealPath() FileUtils.java:161
-> isContainedDirectory(common/) , isContainedDirectory(<type>/) FileUtils.java:164 / :170
-> searchJarFiles(dir) = Files.walk(..., FOLLOW_LINKS) FileUtils.java:73
-> root-level jars at depth 1 FileUtils.java:177
-> new URLClassLoader(jars, parent) CheckpointService.java:82
-> FactoryUtil.discoverFactory(...) under TemporaryClassLoaderContext
-> FileMapStore.init(...) does the same for IMAP storage FileMapStore.java:82-86
Key findings:
- The normal user path (Zeta with the official dist) hits this logic on every start, so the containment guard and the new tests matter.
- The traversal / absolute-path / top-level-symlink vectors from the July review are closed by
STORAGE_TYPE_PATTERNplusisContainedDirectory(FileUtils.java:95, :103). - The
dev-baseline compile break I flagged on 2026-08-24 is gone now thatdevhas the fix, so the new engine tests are finally executed in CI. That is how Issue 2 surfaced.
1.2 Compatibility Impact
Partially incompatible, but mitigated. The legacy flat starter/zeta layout still works through the fallback. The one behavior change is already noted by @SEZ9 (non-blocking Issue 1 in their review): once common/ exists, jars in other sub-directories that the old recursive scan used to pick up are skipped. A WARN plus an upgrade note would be enough.
1.3 Performance / Side-Effect Analysis
One extra directory walk and one URLClassLoader per service at startup; negligible. The loader is intentionally kept for the process lifetime because the storage factory lives that long.
1.4 Error Handling and Logging
The toRealPath() calls are unguarded and the missing-storage-directory case degrades to common/ + root with a success-shaped INFO log; both are covered by @SEZ9's non-blocking items 6 and 7 below.
Issue 1: Containment is only enforced for the top-level directories; the jar walk still follows nested symlinks out of starter/zeta (High, blocking)
- Location:
seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:73(walk),:164-171(containment check) - Problem:
isContainedDirectoryresolves onlycommon/and<type>/, thensearchJarFileswalks them at unbounded depth withFOLLOW_LINKS. A symlinked sub-directory (for examplecommon/deps -> /somewhere/else) or a symlinked*.jar, including at the depth-1 root scan (:177), resolves outside the root and is still loaded into the engine classloader. This defeats the guarantee the Javadoc onisContainedDirectorystates. - Risk: Jars from unrelated filesystem locations end up in the engine classpath.
- Best improvement: Option A: check
path.toRealPath().startsWith(zetaRealPath)for each candidate inside the walk. Option B: walk the split-layout directories withoutFOLLOW_LINKS(legitimate storage jars should not be symlinks). Please add a test for a nested symlink. - Severity: High
- Raised by another reviewer: Yes, @SEZ9 (their Issue 2, review
5018047225); I verified it against the source and agreed in my follow-up comment. +1, still present on this head.
Issue 2: CheckpointServiceStorageClassLoaderTest fails deterministically on Windows (High, blocking, test stability)
- Location:
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CheckpointServiceStorageClassLoaderTest.java:45(@TempDir) and:64(new CheckpointService(checkpointConfig, zetaDirectory)); production sideCheckpointService.java:82 - Evidence: both
unit-test (8, windows-latest)andunit-test (11, windows-latest)fail in the fork run37392693060withtestLoadsCheckpointFactoryFromZetaStarterJar->java.io.IOException: Failed to delete temp directory ... The following paths could not be deleted: , zeta, zeta\s3. - Problem: The test creates a jar under
@TempDir, andCheckpointServiceopens it through aURLClassLoaderthat is intentionally never closed. On Windows an open jar cannot be deleted, so the JUnit temp-dir cleanup fails and the test errors even though the assertion passed. - Best improvement: Option A (smallest): mark the test
@EnabledOnOs({OS.LINUX, OS.MAC}), which is exactly whatFileMapStoreTestin this PR already does; the isolation logic is OS-independent. Option B (keeps Windows coverage): have the@VisibleForTestingconstructor path expose or retain the created loader so the test can close it before cleanup. - Severity: High (a Windows lane that fails on every run blocks the merge gate)
- Raised by another reviewer: No. Sorry again for rating the tests Stable earlier: the Windows jar-lock was visible in the source at that time and I should have caught it.
Non-blocking items I agree with (from @SEZ9's review): Issue 1 (sub-directories silently skipped once common/ exists), Issues 3/4/5 (empty or illegal storage.type falls back to a full recursive scan, which contradicts the "fail closed" comment at FileUtils.java:150-156), Issue 6 (unguarded toRealPath()), Issue 7 (missing storage directory only logs INFO). I still consider these should-fix follow-ups rather than blockers for this change.
2. Code Quality Assessment
2.1 Coding Standards
Core methods are documented; the Javadoc on isContainedDirectory is accurate about intent (see Issue 1 for the gap).
2.2 Test Coverage and Test Stability
FileUtilsTest covers traversal, absolute path and top-level symlink containment (the symlink case is correctly @DisabledOnOs(WINDOWS)); FileMapStoreTest is Linux/Mac only. Stability rating: High risk because of Issue 2 (deterministic Windows failure). Missing coverage: a nested-symlink case for Issue 1.
2.3 Documentation Updates
EN and ZH docs are updated consistently for the new layout.
3. Architectural Soundness
- 3.1 Elegance: Precise fix for the dependency-collision problem, with a legacy fallback.
- 3.2 Maintainability: Reasonable once the fallbacks are made explicit (non-blocking items above).
- 3.3 Extensibility: New storage types only need a new directory in the assembly.
- 3.4 Historical-version compatibility: See 1.2.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Nested symlinks escape the containment check | FileUtils.java:73, :164-177 |
High |
| 2 | Windows unit tests fail: unclosed URLClassLoader blocks @TempDir cleanup |
CheckpointServiceStorageClassLoaderTest.java:45, :64 |
High |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
- Blockers - must be fixed: Issue 1 (+1 to @SEZ9), Issue 2.
- Recommended fixes - non-blocking: @SEZ9's items 1, 3-7 listed above.
CI / merge-gate status on the current head (checked just now): Build is red. The two Windows unit-test jobs are explained by Issue 2. The third red job, engine-v2-it (8, ubuntu-latest), failed in SplitClusterPendingJobLifecycleFailoverIT.testMasterElectionLoopRecoversFromRapidFailoverChurn (a master-election churn test); this PR does not touch election code, so I read it as an unrelated flake (an inference from the log, not reproduced), and it is worth re-running only that failed job after the fixes. A sync with dev is not the missing step here: the branch is 43 commits behind but has no conflicts, and the compile break is already fixed. The remaining gate after the fixes is a green run plus the required committer approval (REVIEW_REQUIRED).
Thanks again for the careful and well-documented work on this, and I am happy to re-review as soon as you push an update.
What does this PR do?
Verify
Notes